package com.eco.fanliapp.service;

import cn.afterturn.easypoi.excel.entity.result.ExcelVerifyHandlerResult;
import cn.afterturn.easypoi.handler.inter.IExcelVerifyHandler;
import com.eco.fanliapp.vo.AppWithdrawalOfMode;

public class ImportAppWithdrawalHandler implements IExcelVerifyHandler<AppWithdrawalOfMode> {


    /*@Override
    public ExcelVerifyHandlerResult verifyHandler(AppWithdrawalOfMode appWithdrawal) {
        String errorMsg = appWithdrawal.getErrorMsg();
        if(errorMsg != null){
            return  new ExcelVerifyHandlerResult(false,"");
        }
        if(appWithdrawal.getApplicantStatus() != null && (appWithdrawal.getApplicantStatus()> 4 || appWithdrawal.getApplicantStatus()< 1)){
            return  new ExcelVerifyHandlerResult(false,"状态值错误");
        }
        IAppUserService appUserServiceImpl = (IAppUserService) SpringContextUtils.getBean("appUserServiceImpl");
        IAppWithdrawalService iAppWithdrawalService = (IAppWithdrawalService) SpringContextUtils.getBean("appWithdrawalServiceImpl");
        ExcelVerifyHandlerResult ExcelVerifyHandlerResult = new ExcelVerifyHandlerResult(true);
        List<AppUser> appUserList = appUserServiceImpl.selectUserByUserNameAndAlipayAccount(appWithdrawal.getUserRealName(),appWithdrawal.getAlipayAccount());
        //用户未找到或者找到多个用户
        if(appUserList.size() != 1){
            ExcelVerifyHandlerResult = new ExcelVerifyHandlerResult(false,"通过用户名和支付宝账号找到多个用户/用户不存在");
        }else {
            //设置用户id
            appWithdrawal.setUserId(appUserList.get(0).getUserId());
            //根据用户id，金额和提现状态 查询提现记录
            List<AppWithdrawal> appWithdrawalList =  iAppWithdrawalService.selectByUserIdAndAmount(appWithdrawal.getUserId(),appWithdrawal.getAmount(),appWithdrawal.getApplicantStatus());
            if(appWithdrawalList.size() != 1){
                ExcelVerifyHandlerResult = new ExcelVerifyHandlerResult(false,"无提现记录/提现记录存在多条/提现记录已处理");
            }
        }
        return ExcelVerifyHandlerResult;
    }*/
    @Override
    public ExcelVerifyHandlerResult verifyHandler(AppWithdrawalOfMode appWithdrawal) {
        String errorMsg = appWithdrawal.getErrorMsg();
        if(errorMsg != null){
            return  new ExcelVerifyHandlerResult(false,"");
        }
        if(appWithdrawal.getApplicantStatus() != null && (appWithdrawal.getApplicantStatus()> 4 || appWithdrawal.getApplicantStatus()< 1)){
            return  new ExcelVerifyHandlerResult(false,"状态值错误");
        }
        ExcelVerifyHandlerResult ExcelVerifyHandlerResult = new ExcelVerifyHandlerResult(true);
        /*IAppUserService appUserServiceImpl = (IAppUserService) SpringContextUtils.getBean("appUserServiceImpl");
        IAppWithdrawalService iAppWithdrawalService = (IAppWithdrawalService) SpringContextUtils.getBean("appWithdrawalServiceImpl");
        List<AppUser> appUserList = appUserServiceImpl.selectUserByUserNameAndAlipayAccount(appWithdrawal.getUserRealName(),appWithdrawal.getAlipayAccount());
        //用户未找到或者找到多个用户
        if(appUserList.size() != 1){
            ExcelVerifyHandlerResult = new ExcelVerifyHandlerResult(false,"通过用户名和支付宝账号找到多个用户/用户不存在");
        }else {
            //设置用户id
            appWithdrawal.setUserId(appUserList.get(0).getUserId());
           *//* //根据用户id，金额和提现状态 查询提现记录
            List<AppWithdrawal> appWithdrawalList =  iAppWithdrawalService.selectByUserIdAndAmount(appWithdrawal.getUserId(),appWithdrawal.getAmount(),appWithdrawal.getApplicantStatus());
            if(appWithdrawalList.size() != 1){
                ExcelVerifyHandlerResult = new ExcelVerifyHandlerResult(false,"无提现记录/提现记录存在多条/提现记录已处理");
            }*//*
        }*/
        return ExcelVerifyHandlerResult;
    }
}
